package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoCollectWorks;
import com.muyu.danmo.service.IDanmoCollectWorksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拾贝作品集Controller
 *
 * @author yangle
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/collectWorks")
public class DanmoCollectWorksController extends BaseController
{
    @Autowired
    private IDanmoCollectWorksService danmoCollectWorksService;

    /**
     * 查询拾贝作品集列表
     */
//    @RequiresPermissions("system:collectWorks:list")
    @PostMapping("/list")
    public Result list(@RequestBody DanmoCollectWorks danmoCollectWorks)
    {
        startPage();
        List<DanmoCollectWorks> list = danmoCollectWorksService.selectDanmoCollectWorksList(danmoCollectWorks);
        return getDataTable(list);
    }

    /**
     * 导出拾贝作品集列表
     */
//    @RequiresPermissions("system:collectWorks:export")
    @Log(title = "拾贝作品集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoCollectWorks danmoCollectWorks)
    {
        List<DanmoCollectWorks> list = danmoCollectWorksService.selectDanmoCollectWorksList(danmoCollectWorks);
        ExcelUtil<DanmoCollectWorks> util = new ExcelUtil<DanmoCollectWorks>(DanmoCollectWorks.class);
        util.exportExcel(response, list, "拾贝作品集数据");
    }

    /**
     * 获取拾贝作品集详细信息
     */
    @RequiresPermissions("system:collectWorks:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoCollectWorksService.selectDanmoCollectWorksById(id));
    }

    /**
     * 新增拾贝作品集
     */
//    @RequiresPermissions("system:collectWorks:add")
    @Log(title = "拾贝作品集", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoCollectWorks danmoCollectWorks)
    {
        return toAjax(danmoCollectWorksService.insertDanmoCollectWorks(danmoCollectWorks));
    }

    /**
     * 修改拾贝作品集
     */
//    @RequiresPermissions("system:collectWorks:edit")
    @Log(title = "拾贝作品集", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoCollectWorks danmoCollectWorks)
    {
        return toAjax(danmoCollectWorksService.updateDanmoCollectWorks(danmoCollectWorks));
    }

    /**
     * 删除拾贝作品集
     */
    @RequiresPermissions("system:collectWorks:remove")
    @Log(title = "拾贝作品集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoCollectWorksService.deleteDanmoCollectWorksByIds(ids));
    }



}
